﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class webmx_Reset : BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            if (Request.Form["txtpwdold"] != null && Request.Form["txtpwd1"] != null && Request.Form["txtpwd2"] != null)
            {
                if (Request.Form["txtpwdold"] != string.Empty && Request.Form["txtpwd1"] != string.Empty && Request.Form["txtpwd2"] != string.Empty)
                {
                    if (Request.Form["txtpwd1"].Equals(Request.Form["txtpwd2"]))
                    {
                        UserActions ua = new UserActions();
                        if (ua.CheckUser(int.Parse(Session["manage"].ToString()), DESEncrypt.Encrypt(Request.Form["txtpwdold"])))
                        {
                            temple_Users u = ManageBase<temple_Users>.Get(int.Parse(Session["manage"].ToString()));
                            u.Password = DESEncrypt.Encrypt(Request.Form["txtpwd1"]);
                            ManageBase<temple_Users>.Set(u);
                            AlertRedirect("操作成功！", "Logout.aspx");
                        }
                        else Alert("原始密码输入错误");
                    }
                    else Alert("两次密码输入不相同，请确认");
                }
                else Alert("新旧密码均不得为空");
            }
            else Alert("请完整填写表单");
        }
    }
}